package com.tiancheng.trade.settlement.controller.admin;

import com.tiancheng.trade.commom.core.data.Result;
import com.tiancheng.trade.settlement.service.settlement.IClearBankDetailCmbService;
import com.tiancheng.trade.settlement.service.settlement.IClearBankSummaryCmbService;
import com.tiancheng.trade.settlement.vo.settlement.admin.ClearCmbExportQueryVO;
import com.tiancheng.trade.settlement.vo.settlement.admin.ClearCmbQueryVO;
import com.tiancheng.trade.settlement.vo.settlement.admin.ClearDetailCmbExportQueryVO;
import com.tiancheng.trade.settlement.vo.settlement.admin.ClearDetailCmbQueryVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 清分对账(招行)
 */
@RestController
@RequestMapping("/admin/clear")
@Validated
@Slf4j
public class ClearCmbController {

    @Autowired
    IClearBankSummaryCmbService clearBankSummaryCmbService;

    @Autowired
    IClearBankDetailCmbService clearBankDetailCmbService;

    /**
     * 对账单汇总，分页查询
     *
     * @param clearCmbQueryVo 查询条件
     * @return
     */
    @GetMapping("/summary/")
    public Result findPageList(ClearCmbQueryVO clearCmbQueryVo) {
        return Result.success(clearBankSummaryCmbService.findPageList(clearCmbQueryVo));
    }

    /**
     * 对账单汇总，导出
     *
     * @param clearCmbDownloadQueryVo
     * @return
     */
    @GetMapping(value = "/summary/export/")
    public Result getExport(ClearCmbExportQueryVO clearCmbDownloadQueryVo, HttpServletRequest request, HttpServletResponse response) throws IOException {
        clearBankSummaryCmbService.export(clearCmbDownloadQueryVo, request, response);
        return Result.success("导出成功");
    }

    /**
     * 对账单明细，分页查询
     *
     * @param clearDetailCmbQueryVo 查询条件
     * @return
     */
    @GetMapping("/detail/")
    public Result findPageListDetail(ClearDetailCmbQueryVO clearDetailCmbQueryVo) {
        return Result.success(clearBankDetailCmbService.findPageList(clearDetailCmbQueryVo));
    }

    /**
     * 对账单明细，导出
     *
     * @param clearDetailCmbExportQueryVo
     * @return
     */
    @GetMapping(value = "/detail/export/")
    public Result getDetailExport(ClearDetailCmbExportQueryVO clearDetailCmbExportQueryVo, HttpServletRequest request, HttpServletResponse response) throws IOException {
        clearBankDetailCmbService.export(clearDetailCmbExportQueryVo, request, response);
        return Result.success("导出成功");
    }

}
